package com.ruoyi.aero.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.aero.domain.GroupInfo;
import com.ruoyi.aero.service.IGroupInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 班组信息Controller
 * 
 * @author swb
 * @date 2024-06-04
 */
@RestController
@RequestMapping("/aero/group")
public class GroupInfoController extends BaseController
{
    @Autowired
    private IGroupInfoService groupInfoService;

    /**
     * 查询班组信息列表
     */
    @PreAuthorize("@ss.hasPermi('aero:group:list')")
    @GetMapping("/list")
    public TableDataInfo list(GroupInfo groupInfo)
    {
        startPage();
        List<GroupInfo> list = groupInfoService.selectGroupInfoList(groupInfo);
        return getDataTable(list);
    }

    /**
     * 导出班组信息列表
     */
    @PreAuthorize("@ss.hasPermi('aero:group:export')")
    @Log(title = "班组信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GroupInfo groupInfo)
    {
        List<GroupInfo> list = groupInfoService.selectGroupInfoList(groupInfo);
        ExcelUtil<GroupInfo> util = new ExcelUtil<GroupInfo>(GroupInfo.class);
        util.exportExcel(response, list, "班组信息数据");
    }

    /**
     * 获取班组信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('aero:group:query')")
    @GetMapping(value = "/{groupId}")
    public AjaxResult getInfo(@PathVariable("groupId") String groupId)
    {
        return success(groupInfoService.selectGroupInfoByGroupId(groupId));
    }

    /**
     * 新增班组信息
     */
    @PreAuthorize("@ss.hasPermi('aero:group:add')")
    @Log(title = "班组信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GroupInfo groupInfo)
    {
        return toAjax(groupInfoService.insertGroupInfo(groupInfo));
    }

    /**
     * 修改班组信息
     */
    @PreAuthorize("@ss.hasPermi('aero:group:edit')")
    @Log(title = "班组信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GroupInfo groupInfo)
    {
        return toAjax(groupInfoService.updateGroupInfo(groupInfo));
    }

    /**
     * 删除班组信息
     */
    @PreAuthorize("@ss.hasPermi('aero:group:remove')")
    @Log(title = "班组信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{groupIds}")
    public AjaxResult remove(@PathVariable String[] groupIds)
    {
        return toAjax(groupInfoService.deleteGroupInfoByGroupIds(groupIds));
    }
}
